* Load File
import delimited "/Users/josephphillips/Dropbox/Projects/Dissertation/REAL Chapter 1 Stability/ANES Cumulative IE Non-Imputed.csv", encoding(ISO-8859-1)

* destring variables
replace ideosort="." if ideosort=="NA"
destring ideosort, replace
replace socialsort="." if socialsort=="NA"
destring socialsort, replace
replace gender="." if gender=="NA"
destring gender, replace
replace black="." if black=="NA"
destring black, replace
replace education="." if education=="NA"
destring education, replace
replace ideo="." if ideo=="NA"
destring ideo, replace
replace attendance="." if attendance=="NA"
destring attendance, replace
replace south="." if south=="NA"
destring south, replace
replace polariznew="." if polariznew=="NA"
destring polariznew, replace
replace polarizold="." if polarizold=="NA"
destring polarizold, replace
replace polarizcombined="." if polarizcombined=="NA"
destring polarizcombined, replace
replace polarizlikes="." if polarizlikes=="NA"
destring polarizlikes, replace
replace inpartynew="." if inpartynew=="NA"
destring inpartynew, replace
replace inpartyold="." if inpartyold=="NA"
destring inpartyold, replace
replace inpartycombined="." if inpartycombined=="NA"
destring inpartycombined, replace
replace inpartylikes="." if inpartylikes=="NA"
destring inpartylikes, replace
replace outpartynew="." if outpartynew=="NA"
destring outpartynew, replace
replace outpartyold="." if outpartyold=="NA"
destring outpartyold, replace
replace outpartycombined="." if outpartycombined=="NA"
destring outpartycombined, replace
replace outpartylikes="." if outpartylikes=="NA"
destring outpartylikes, replace
replace agegroup="." if agegroup=="NA"
destring agegroup, replace
replace yeargroup="." if yeargroup=="NA"
destring yeargroup, replace
replace yeargroupold="." if yeargroupold=="NA"
destring yeargroupold, replace
replace yeargroupoldna="." if yeargroupoldna=="NA"
destring yeargroupoldna, replace
replace yeargrouplikesna="." if yeargrouplikesna=="NA"
destring yeargrouplikesna, replace
replace cohort="." if cohort=="NA"
destring cohort, replace
replace cohortold="." if cohortold=="NA"
destring cohortold, replace
replace cohortlikes="." if cohortlikes=="NA"
destring cohortlikes, replace
replace cohortcombined="." if cohortcombined=="NA"
destring cohortcombined, replace

* Table A2
** Model 1
apc_ie polariznew, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 2
apc_ie polariznew strong, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 3
apc_ie polariznew ideosort socialsort, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 4
apc_ie polariznew gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 5
apc_ie polariznew strong gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 6
apc_ie polariznew ideosort socialsort gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)

* Table A4
** Model 1 (for left panel of Figures A1-A3, see Appendices APCI.R)
apc_ie polariznew if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 2
apc_ie polariznew strong if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 3
apc_ie polariznew ideosort socialsort if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 4
apc_ie polariznew gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 5
apc_ie polariznew strong gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 6
apc_ie polariznew ideosort socialsort gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)

* Table A6
** Model 1 (for left panel of Figures A5-A7, see Appendices APCI.R)
apc_ie polariznew if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 2
apc_ie polariznew strong if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 3
apc_ie polariznew ideosort socialsort if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 4
apc_ie polariznew gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 5
apc_ie polariznew strong gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 6
apc_ie polariznew ideosort socialsort gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)

* Table A8
** Model 1 (for left panel of Figures A9-A11, see Appendices APCI.R)
apc_ie polarizcombined, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 2
apc_ie polarizcombined strong, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 3
apc_ie polarizcombined ideosort socialsort, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 4
apc_ie polarizcombined gender black education ideo attendance south, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 5
apc_ie polarizcombined strong gender black education ideo attendance south, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 6
apc_ie polarizcombined ideosort socialsort gender black education ideo attendance south, age(agegroup) period(yeargroupold) family(gaussian) link(identity)

* Table A10
** Model 1 (for left panel of Figures A13-A15, see Appendices APCI.R)
apc_ie polarizcombined if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 2
apc_ie polarizcombined strong if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 3
apc_ie polarizcombined ideosort socialsort if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 4
apc_ie polarizcombined gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 5
apc_ie polarizcombined strong gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 6
apc_ie polarizcombined ideosort socialsort gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)

* Table A12
** Model 1 (for left panel of Figures A17-A19, see Appendices APCI.R)
apc_ie polarizcombined if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 2
apc_ie polarizcombined strong if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 3
apc_ie polarizcombined ideosort socialsort if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 4
apc_ie polarizcombined gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 5
apc_ie polarizcombined strong gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 6
apc_ie polarizcombined ideosort socialsort gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)

* Table A14
** Model 1 (for left panel of Figures A21-A23, see Appendices APCI.R)
apc_ie inpartynew, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 2
apc_ie inpartynew strong, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 3
apc_ie inpartynew ideosort socialsort, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 4
apc_ie inpartynew gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 5
apc_ie inpartynew strong gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 6
apc_ie inpartynew ideosort socialsort gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)

* Table A16
** Model 1 (for left panel of Figures A25-A27, see Appendices APCI.R)
apc_ie inpartynew if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 2
apc_ie inpartynew strong if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 3
apc_ie inpartynew ideosort socialsort if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 4
apc_ie inpartynew gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 5
apc_ie inpartynew strong gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 6
apc_ie inpartynew ideosort socialsort gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroup) family(gaussian) link(identity)

* Table A18
** Model 1 (for left panel of Figures A28-A30, see Appendices APCI.R)
apc_ie inpartynew if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 2
apc_ie inpartynew strong if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 3
apc_ie inpartynew ideosort socialsort if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 4
apc_ie inpartynew gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 5
apc_ie inpartynew strong gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 6
apc_ie inpartynew ideosort socialsort gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroup) family(gaussian) link(identity)

* Table A20
** Model 1 (for left panel of Figures A33-A35, see Appendices APCI.R)
apc_ie inpartycombined, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 2
apc_ie inpartycombined strong, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 3
apc_ie inpartycombined ideosort socialsort, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 4
apc_ie inpartycombined gender black education ideo attendance south, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 5
apc_ie inpartycombined strong gender black education ideo attendance south, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 6
apc_ie inpartycombined ideosort socialsort gender black education ideo attendance south, age(agegroup) period(yeargroupold) family(gaussian) link(identity)

* Table A22
** Model 1 (for left panel of Figures A37-A39, see Appendices APCI.R)
apc_ie inpartycombined if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 2
apc_ie inpartycombined strong if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 3
apc_ie inpartycombined ideosort socialsort if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 4
apc_ie inpartycombined gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 5
apc_ie inpartycombined strong gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 6
apc_ie inpartycombined ideosort socialsort gender black education ideo attendance south if pid<=3, age(agegroup) period(yeargroupold) family(gaussian) link(identity)

* Table A24
** Model 1 (for left panel of Figures A40-A42, see Appendices APCI.R)
apc_ie inpartycombined if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 2
apc_ie inpartycombined strong if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 3
apc_ie inpartycombined ideosort socialsort if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 4
apc_ie inpartycombined gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 5
apc_ie inpartycombined strong gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)
** Model 6
apc_ie inpartycombined ideosort socialsort gender black education ideo attendance south if pid>=5, age(agegroup) period(yeargroupold) family(gaussian) link(identity)

* Table A26
** Model 1
apc_ie outpartynew, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 2
apc_ie outpartynew strong, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 3
apc_ie outpartynew ideosort socialsort, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 4
apc_ie outpartynew gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 5
apc_ie outpartynew strong gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)
** Model 6
apc_ie outpartynew ideosort socialsort gender black education ideo attendance south, age(agegroup) period(yeargroup) family(gaussian) link(identity)
